package cn.lumora.enums;

import java.util.Arrays;


public enum LoginTypeEnum {
    PASSWORD(0, "passwordLoginStrategy"),
    SMS_CODE(1, "smsCodeLoginStrategy");

    private final int code;
    private final String beanName;

    LoginTypeEnum(int code, String beanName) {
        this.code = code;
        this.beanName = beanName;
    }

    public static String getBeanNameByCode(int code) {
        return Arrays.stream(values())
                .filter(type -> type.code == code)
                .findFirst()
                .map(LoginTypeEnum::getBeanName)
                .orElseThrow(() -> new IllegalArgumentException("不支持的登录类型: " + code));
    }

    public int getCode() {
        return code;
    }

    public String getBeanName() {
        return beanName;
    }
}
